<?php

namespace app\common\library\util;
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver;
/**
 * 图片的处理
 */
class Image
{
    /**
     * 缩放图片的宽度
     * @param $file
     * @param $width
     * @return true
     */
    public static function thumb($file = '',$width = 500){
        $manager = new ImageManager(
            new Driver()
        );

        // open an image file
        $image = $manager->read($file);

        $image->scale($width);

        $encoded = $image->toJpg();

        // save encoded image
        $encoded->save($file);

        return true;
    }
}